home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 780 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. From: bkline@cortex.nlm.nih.gov (Bob Kline)
  2. Message-ID: <4ikjlp$jbr@lhc.nlm.nih.gov>
  3. X-Original-Date: 18 Mar 1996 21:13:29 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 19 Mar 96 11:17:49 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: istrstreams and width
  9. Organization: National Library of Medicine
  10. References: <4ibvn8$4gr@venus.roc.csci.csc.com>
  11. X-Newsreader: TIN [version 1.2 PL2]
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMU6YEeEDnX0m9pzZAQHn3AF+IlSfaS4kPd1hcPg+07uglxrUHHf5Okaj
  14.     tZYAPr4BGrkksl5znqXkhp5mNbFOrZfZ
  15.     =6nv2
  16.  
  17. I have asked this question (with respect to the istream spec in general)
  18. from time to time in this forum, and (until reading your article) have 
  19. always attributed the lack of response to the theory that everyone else 
  20. on the newsgroup was too young to understand what I was talking about.
  21. :->}  Seriously, though, it would be nice if the newer I/O model provided
  22. at least the level of support for formatted I/O as the model it purports
  23. to replace, but there doesn't seem to be much interest.
  24.  
  25. Tim Ottinger (tottinge@csci.csc.com) wrote:
  26. : We've already worked around this (identified two way to do so) but we 
  27. : wonder why it doesn't work this way:
  28.  
  29. : Given:
  30. :     istrstream source;
  31. :     int i;
  32. :     string s;
  33. :     source >> setw(2) >> i >> s;
  34.  
  35. : With fixed length fields (yes, we have to read mainframe data from time to 
  36. : time, and a few other odd sources), sometimes the fields are butted up
  37. : against each other, and sometimes the strings have initial digit characters
  38. : i them.
  39.  
  40. : When the stream contains "01115 N Neil", it would be nice if "01" and
  41. : "115 N Neil" were broken out, but every compiler we try pulls "01115"
  42. : as the number, and "N Neil" is the string.
  43.  
  44. : Of course, if we insert whitespace or use read, this works.  And we should
  45. : use read() because we're doing fixed length, but I was wondering why setw()
  46. : doesn't apply to integer extractors.
  47.  
  48. : Surely a lot of people have to read fixed-length records, and this is a
  49. : common thing.
  50.  
  51. : Any thoughts?
  52. : Tim
  53.  
  54. --
  55. /*----------------------------------------------------------------------*/
  56. /* Bob Kline                                       Stream International */
  57. /* bob_kline@stream.com               formerly Corporate Software, Inc. */
  58. /* voice: (703) 522-0820 x-311                      fax: (703) 522-5407 */
  59. /*----------------------------------------------------------------------*/
  60. ---
  61. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  62. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  63. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  64. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  65. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  66.